package com.atguigu.study.config;

import com.atguigu.study.service.ChatAssistant;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @auther zzyy
 * @create 2025-03-11 16:43
 */
@Configuration(proxyBeanMethods = false)
public class ChatModelConfig {

    // @Bean
    // public ChatModel chatModel()
    // {
    //     return
    //         OpenAiChatModel.builder()
    //                 // 将key定义到系统变量，然后读取
    //                 .apiKey(System.getenv("LANGCHAIN4J_KEY"))
    //                 .modelName("qwen-turbo")
    //                 .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
    //         .build();
    // }


    @Bean
    public ChatModel chatModel() {
        return
            OpenAiChatModel.builder()
                .apiKey("sk-b24d81b5fd154764a360ca433838ac47")
                .modelName("deepseek-chat")
                //.modelName("deepseek-reasoner")
                .baseUrl("https://api.deepseek.com/v1")
                .build();
    }


    // 你使用第2种类，高阶API    AiService
    @Bean
    public ChatAssistant chatAssistant(ChatModel chatModel) {
        return AiServices.create(ChatAssistant.class, chatModel);
    }
}

